<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
			用户名：<input type="text" name="username" id="username" value="" />
			<br />
			<input type="submit" name="sub" id="sub" value="提交" />
			<div id="msg"></div>
			<script src="http://cdn.static.runoob.com/libs/jquery/1.10.2/jquery.min.js"></script>
			<script>
				$(function(){
					$("#sub").bind("click",function(event){
						var username=$("#username").val();
						console.info(username);
						if(username==""){
								$("#msg").html("<p>用户名不能为空</p>");
								event.defaultPrevented();
						}
					})
				})
			</script>
	</body>
</html>
